package com.lin.test.modle;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

/**
 * Created by 林云志 on 2018/9/19.
 */
public class Base {
    public Base(){
        try {
            Method[] ms = this.getClass().getMethods();
            Properties pro = new Properties();
            pro.load(Base.class.getClassLoader().getResourceAsStream("beans.properties"));
            for (Method m:ms){
                if (m.isAnnotationPresent(Inject.class)){
                    String mname = m.getName();
                    mname = mname.substring(3);
                    mname = mname.substring(0,1).toLowerCase()+mname.substring(1);
                    System.out.println(mname);
                    String cname = (String) pro.get(mname);
                    Object o = Class.forName(cname).newInstance();
                    m.invoke(this,o);

                }
            }

        }catch (Exception e){

        }
    }
}
